<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>避免数组重复渲染</title>
    <script src="https://unpkg.com/vue@next"></script>
</head>
<body>
    <div id="app"></div>
</body>
<script>
     app = Vue.createApp({
        data(){
            return{
                list:['红','橙','黄'],
                duixiang:{
                    name:'hong',
                    age:12,
                    sex:1
                }
            }
        },
        methods:{
            onclick(){
                this.list.push('绿');
            }
        },
       
        template:`
        <button @click="onclick">添加</button>
        <h2 v-for="(item,index) of list" :key="index+item">[{{index}}]{{item}}</h2>
        const<h2 v-for="(value,key,index) of duixiang" :key="key">[{{index}}]{{key}}--{{value}}</h2>`
    })
    const vm = app.mount("#app")
</script>
</html>